using CollabApp.Application.DTOs.Game;
using CollabApp.Domain.ValueObjects;

namespace CollabApp.Application.Interfaces
{
    /// <summary>
    /// 画线圈地游戏服务接口
    /// </summary>
    public interface ILineDrawingGameService
    {
        /// <summary>
        /// 处理玩家移动
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="newPosition">新位置</param>
        /// <param name="timestamp">时间戳</param>
        /// <returns>移动处理结果</returns>
        Task<LineDrawingMoveResult> ProcessPlayerMoveAsync(Guid gameId, Guid playerId, Position newPosition, long timestamp);

        /// <summary>
        /// 开始画线
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="startPosition">起始位置</param>
        /// <param name="timestamp">时间戳</param>
        /// <returns>开始画线结果</returns>
        Task<LineDrawingResult> StartDrawingAsync(Guid gameId, Guid playerId, Position startPosition, long timestamp);

        /// <summary>
        /// 添加画线路径点
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="pathPoint">路径点</param>
        /// <param name="timestamp">时间戳</param>
        /// <returns>画线结果</returns>
        Task<LineDrawingResult> AddPathPointAsync(Guid gameId, Guid playerId, Position pathPoint, long timestamp);

        /// <summary>
        /// 完成圈地（路径闭合）
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="endPosition">结束位置</param>
        /// <param name="timestamp">时间戳</param>
        /// <returns>圈地结果</returns>
        Task<TerritoryClaimResult> CompleteDrawingAsync(Guid gameId, Guid playerId, Position endPosition, long timestamp);

        /// <summary>
        /// 检查碰撞并处理死亡
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="currentPath">当前路径</param>
        /// <returns>碰撞检测结果</returns>
        Task<CollisionCheckResult> CheckCollisionAsync(Guid gameId, Guid playerId, List<Position> currentPath);

        /// <summary>
        /// 拾取道具
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="powerUpId">道具ID</param>
        /// <param name="timestamp">时间戳</param>
        /// <returns>拾取结果</returns>
        Task<PowerUpPickupResult> PickupPowerUpAsync(Guid gameId, Guid playerId, Guid powerUpId, long timestamp);

        /// <summary>
        /// 使用道具
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="powerUpType">道具类型</param>
        /// <param name="timestamp">时间戳</param>
        /// <returns>使用结果</returns>
        Task<PowerUpUseResult> UsePowerUpAsync(Guid gameId, Guid playerId, PowerUpType powerUpType, long timestamp);

        /// <summary>
        /// 处理玩家死亡
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">死亡玩家ID</param>
        /// <param name="killerPlayerId">击杀玩家ID</param>
        /// <param name="deathReason">死亡原因</param>
        /// <param name="timestamp">时间戳</param>
        /// <returns>死亡处理结果</returns>
        Task<PlayerDeathResult> ProcessPlayerDeathAsync(Guid gameId, Guid playerId, Guid? killerPlayerId, string deathReason, long timestamp);

        /// <summary>
        /// 处理玩家复活
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="timestamp">时间戳</param>
        /// <returns>复活结果</returns>
        Task<PlayerRespawnResult> ProcessPlayerRespawnAsync(Guid gameId, Guid playerId, long timestamp);

        /// <summary>
        /// 获取玩家当前状态
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <returns>玩家状态</returns>
        Task<LineDrawingPlayerState?> GetPlayerStateAsync(Guid gameId, Guid playerId);

        /// <summary>
        /// 获取游戏状态快照
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <returns>游戏状态</returns>
        Task<LineDrawingGameState?> GetGameStateAsync(Guid gameId);

        /// <summary>
        /// 计算实时排名
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <returns>排名列表</returns>
        Task<List<PlayerRankingDto>> GetRealTimeRankingAsync(Guid gameId);

        /// <summary>
        /// 创建新游戏
        /// </summary>
        /// <param name="roomCode">房间代码</param>
        /// <param name="settings">游戏设置</param>
        /// <param name="hostPlayerId">房主玩家ID</param>
        /// <param name="hostPlayerName">房主玩家名称</param>
        /// <returns>创建结果</returns>
        Task<GameCreationResult> CreateGameAsync(string roomCode, GameSettings settings, Guid hostPlayerId, string hostPlayerName);

        /// <summary>
        /// 加入游戏
        /// </summary>
        /// <param name="roomCode">房间代码</param>
        /// <param name="playerId">玩家ID</param>
        /// <param name="playerName">玩家名称</param>
        /// <returns>加入结果</returns>
        Task<GameJoinResult> JoinGameAsync(string roomCode, Guid playerId, string playerName);

        /// <summary>
        /// 开始游戏
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="hostPlayerId">房主玩家ID</param>
        /// <returns>开始结果</returns>
        Task<GameStartResult> StartGameAsync(Guid gameId, Guid hostPlayerId);

        /// <summary>
        /// 离开游戏
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <returns>离开结果</returns>
        Task<GameLeaveResult> LeaveGameAsync(Guid gameId, Guid playerId);

        /// <summary>
        /// 玩家复活
        /// </summary>
        /// <param name="gameId">游戏ID</param>
        /// <param name="playerId">玩家ID</param>
        /// <returns>复活结果</returns>
        Task<PlayerRespawnResult> RespawnPlayerAsync(Guid gameId, Guid playerId);
    }
}